\section{eval --- Evaluate expression}
\label{fn:eval}
\index{eval()}
\index{evaluate expression}
\begin{rail}
Eval : 'eval' '(' String ')' ;
\end{rail}

\verb+eval+ is a way to make up commands and functions at execution time.
You do not gain much by using this function during an interactive
session, however it can be very useful when called from a script. 

The expression contained in the string argument is evaluated without
regard to local functions.  Essentially what occurs is equivalent to 
replacing the \verb+eval+ function with the contents of the
string in a {\em global} context.  Any assignments or variable
modifications will effect the global symbol table only.

\verb+eval+ does not have any knowledge of local variables. Thus if
you use \verb+eval+ within a user-defined function, you must be
careful not to reference that function's arguments or local variables.

$\Longrightarrow$ This is not an \RLaB\ built-in function.  This function
is normally loaded on start-up from the \verb+eval.r+ file in the
standard \verb+rlib+ directory. Use of the \verb+-r+ option, incorrectly 
setting the \verb+RLAB_LIB_DIR+ environmental variable, or modifying
\verb+eval.r+ may make this function unavailable.

\paragraph{Example}
\index{example of eval()}
\index{eval()!example}
\begin{verbatim}
> eval("a = cos(0)")
 a =
        1
        0
> eval("a = sin(sqrt(2)/2)");
 a =
     0.65
> eval("b = tan(3);")
        0
> b
 b =
   -0.143
> printf( "Enter a function: " ); x = getline( "stdin" );
Enter a function: sqrt
> // this could be in a function
> eval("tmp = " + x.[1] + "(" + "3" + ")" );
 tmp =
     1.73
> printf( "Enter a function: " ); x = getline( "stdin" );
Enter a function: tanh
> eval("tmp = " + x.[1] + "(" + "3" + ")" );
 tmp =
    0.995
\end{verbatim}

\newpage




